import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { SequelizeModule } from '@nestjs/sequelize';
import { DatabaseModule } from 'src/database/database.module';
import { AccessoryProviders } from '../accessory/provider/accessory.providers';
import { RpAccount } from '../account/entity/account.entity';
import { AccountService } from '../account/service/account.service';
import { jwtConstants } from '../auth/constants';
import { RoleEntity } from '../role/entity/role.entity';
import { RoleProviders } from '../role/providers/role.providers';
import { RoleService } from '../role/service/role.service';
import { MenuController } from './controller/menu.controller';
import { MenuEntity } from './entity/menu.entity';
import { MenuProviders } from './provider/menu.providers';
import { MenuService } from './service/menu.service';

@Module({
  controllers: [MenuController],
  imports: [
    DatabaseModule,
    JwtModule.register({
      secret: jwtConstants.secret,
      signOptions: { expiresIn: jwtConstants.expiresSecond }, // token 过期时效
    }),
    SequelizeModule.forFeature([MenuEntity, RoleEntity, RpAccount]),
  ],
  providers: [
    MenuService,
    RoleService,
    AccountService,
    ...MenuProviders,
    ...RoleProviders,
    ...AccessoryProviders,
  ],
})
export class MenuModule {}
